<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>矩形的周长和面积计算</h1>
    <label>宽度：</label>
    <input type="text" id="width"/>
    <label>高度：</label>
    <input type="text" id="height"/>
    <button onclick="count()">计算</button>
    <label>周长：</label>
    <input type="text" id="zc"/>
    <label>面积：</label>
    <input type="text" id="area"/>
</body>
<script>
    function count(){//点击触发函数
    let width = document.getElementById("width").value;//获取矩形的宽
    let height = document.getElementById("height").value;//获取矩形的高
    
    console.log(width);//打印宽度
    console.log(height);//打印高度
    document.getElementById("zc").value = 2*(parseInt(width) + parseInt(height));//计算矩形周长
    document.getElementById("area").value = (width)*(height);//计算矩形面积
    console.log(zc.value);//打印矩形周长
    console.log(area.value);//打印矩形面积
    }
    
</script>
</html>